{include file="public/header"}
<title>订单录入</title>
</head>
<body>
<style>
    .col-sm-9 {
        width: 29%;
    }
    .form-label {
        width: 29%;
    }
</style>

<article class="page-container" >
    <form action="" method="post" class="form form-horizontal" id="form-member-add">
        <input type="hidden"   name="order_id" value="{$data}" >

        <div class="ch-row ch-info-form">
            <p class="flex1"><span class="c-red">*</span>选择合同方式：</p>
            <div class="flex2 ch-pc-row">
                <div class="ch-radio shi">
                    <input type="radio" id="radio1" name="pro_types" value="0" <?php if($contr["weixin"]==1){?> checked="checked" <?php }?>>
                    <label for="radio1">使用合同照片</label>
                </div>
                <div class="ch-radio dian" data-id="{$data}">
                    <input type="radio" id="radio2" name="pro_types" value="1" <?php if($contr["weixin"]==2){?> checked="checked" <?php }?>>
                    <label for="radio2">使用电子合同</label>
                </div>
            </div>
        </div>
        <div class="photo ch-row" <?php if($contr["weixin"]==2 || empty($contr["weixin"])){?> style="overflow: hidden; height: 0;" <?php }else{?> style=" height: auto;" <?php }?>
            <div class="ch-row ch-info-form">
                <div class="flex1"></div>
                <div class="flex2 ch-row">
                    <div id="uploader-demo"style="margin-right: 10px">
                            <!--用来存放item-->
                        <div id="fileList" class="uploader-list">
                            <?php if(is_array($contr['logo']))foreach($contr['logo'] as $user){ ?>
                            <div id="" class="file-item thumbnail">
                                <div onclick="delParent(this)" style="cursor: pointer;background: url({$Think.DOMAIN_SRC}/static/h-ui/images/del.png) no-repeat;background-size:contain;height: 20px;width: 20px;position: absolute;z-index: 10;right: 5px;"></div>
                                <img style="width: 100px;height: 100px;" src="<?php echo $user ?>">
                                <input name="logo[]" type="hidden" value="<?php echo $user ?>">
                                <div class="info"></div>
                            </div>
                            <?php } ?>
                        </div>
                        <div id="filePicker">上传合同照片</div>
                    </div>
                </div>
                
            </div>
            
        </div>

        <div class="ch-row ch-info-form" style="margin-top: 50px;">
            <p class="flex1"><span class="c-red">*</span>支付方式：</p>
            <div class="flex2 ch-pc-row">
                <div class="ch-radio xiao"  data-id="{$data}">
                    <input type="radio" id="radio3" name="weixin" value="2" <?php if($contr["weixin"]==2){?> checked="checked" <?php }?>>
                    <label for="radio3">用户小程序支付</label>
                </div>
                <div class="ch-radio xian"  data-id="{$data}">
                    <input type="radio" id="radio4" name="weixin" value="1"  <?php if($contr["weixin"]==1){?> checked="checked" <?php }?>>
                    <label for="radio4">微信/支付宝/现金/淘宝</label>
                </div>
            </div>
        </div>
        <div class="ch-row ch-info-form jin">
            <p class="flex1"><span class="c-red">*</span>请添加支付金额：</p>
            <div class="flex2">
                <input type="text" class="form-control " value="{$contr['dep_money']}" name="dep_money"  placeholder="请输入金额">
                <span style="color:red">剩余金额：{$p}</span>
            </div>
        </div>
        <div class="ch-row fa" <?php if($contr["weixin"]==2 || empty($contr["weixin"])){?> style="overflow: hidden; height: 0;" <?php }else{?> <?php }?> >
            <div class="flex1"></div>
            <div class="flex2">
                <div id="uploader-demos">
                    <!--用来存放item-->

                    <div id="fileLists" class="uploader-list">
                        <?php if(is_array($contr['logos']))foreach($contr['logos'] as $user){ ?>
                        <div id="" class="file-item thumbnail">
                            <div onclick="delParent(this)" style="cursor: pointer;background: url({$Think.DOMAIN_SRC}/static/h-ui/images/del.png) no-repeat;background-size:contain;height: 20px;width: 20px;position: absolute;z-index: 10;right: 5px;"></div>
                            <img style="width: 100px;height: 100px;" src="<?php echo $user ?>">
                            <input name="logos[]" type="hidden" value="<?php echo $user ?>">
                            <div class="info"></div>
                        </div>
                        <?php } ?>
                    </div>
                    <div id="filePickers">上传定金发票</div>
                </div>
            </div>
        </div>
            
        <!-- <div class="ch-row ch-info-form">
            <p class="flex1"><span class="c-red">*</span>纸质合同：</p>
            <div class="flex2">
                <a class="btn btn-primary shi" href="javascript:;" title="使用合同照片">使用合同照片</a>
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <p class="flex1"><span class="c-red">*</span>电子合同：</p>
            <div class="flex2">
                <a class="btn btn-primary dian"  data-id="{$data}" href="javascript:;" title="使用合同照片">使用电子合同</a>
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <p class="flex1"><span class="c-red">*</span>设置支付：</p>
            <div class="flex2">
                <a class="btn btn-primary xiao"  data-id="{$data}" href="javascript:;" title="使用合同照片">用户小程序支付</a>
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <p class="flex1"></p>
            <div class="flex2">
                <a class="btn btn-primary xian"  data-id="{$data}" href="javascript:;" title="使用合同照片">微信/支付宝/现金/淘宝</a>
            </div>
        </div> -->

        

        
        
        <!--<div class="row cl">-->
            <!--<label class="form-label col-xs-4 col-sm-1">定金时间：</label>-->
            <!--<div class="formControls col-xs-8 col-sm-9">-->
                <!--<input type="datetime-local" class="form-control"  name="dep_time" >-->

            <!--</div>-->
        <!--</div>-->
        <!--<div class="row cl">-->
            <!--<label class="form-label col-xs-4 col-sm-1">定金金额：</label>-->
            <!--<div class="formControls col-xs-8 col-sm-9">-->
                <!--<input type="text" class="form-control"  name="dep_money" placeholder="请输入金额">-->
            <!--</div>-->
        <!--</div>-->


        <div class="ch-row ch-info-form">
            <!--<div class="flex1">-->
                <!--<button class="btn btn-primary radius" type="button" value="0" style="margin-right: 10px;"><i class="Hui-iconfont">&#xe632;</i> 保存信息</button>-->
            <!--</div>-->
            <div class="flex2">
                <button class="btn btn-success radius" type="button" value="1" style="margin-left: 10px;"><i class="Hui-iconfont">&#xe632;</i> 确认成交</button>
            </div>
        </div>
        <input type="hidden" name="baocun" id="baocun">
    </form>
</article>
{include file="public/footer"}
<script>
    $(".form_datetime").datetimepicker({format: 'yyyy-mm-dd hh:ii'});
    $('.radius').click(function () {
        $('#baocun').val($(this).val());
        var src="{:Url('index/order/que')}";
        $.ajax({
            type: 'POST',
            url: src,
            dataType: 'json',
            data:$('form').serializeArray(),
            success: function (data) {
                var res=JSON.parse(data);
                if(res.code==200){
                    layer.msg(res.msg, {icon: 1, time: 2000}, function (index,layero) {
                        setTimeout("window.parent.location.reload()", 1);
                    });
                }else{
                    layer.msg(res.msg,{icon: 5,time:1000});
                }

            },
            error: function (data) {
                console.log(data.msg);
            },
        });

    });
        /*
        **
        **上传合同
         */
    $("#img-change").click(function () {
        $("#file").click();
    });

    $(".shi").click(function () {
        $('.photo').css('height','auto');
    });
    $(".xiao").click(function () {
        $('.jin').show();
        $(".fa").css({'height':'0','overflow':'hidden'});
    });
    $(".xian").click(function () {
        $('.jin').show();
        $(".fa").css('height','auto');

    });
    $(".dian").click(function () {
        $('.photo').css({'height':'0','overflow':'hidden'});

        var id = $(this).attr('data-id');
        var src = "{:Url('index/order/he')}";
        layer.open({
            type: 2,
            area: ['100%', '100%'],
            scrollbar: true ,//屏蔽浏览器滚动条
            shade: 0.4,
            title: '查看合同',
            content: src + '?order_id=' + id+'&type=1'
        });
    });

    function delParent(object){
        $(object).parent().remove();
        count-=1;
    }
    var count=1;
    $(function(){
        var $list = $("#fileList");
        var uploader = WebUploader.create({
            auto: true,
            // 文件接收服务端。
            server: "{:Url('index/upload/upload_file')}",

            // 选择文件的按钮。可选。
            pick: '#filePicker',

            // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
            resize: false,
            duplicate:true,
            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: 'image/*'
            },
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            var $li = $(
                    '<div id="' + file.id + '" class="file-item thumbnail">' +
                    '<div onclick="delParent(this)" style="cursor: pointer;background: url({$Think.DOMAIN_SRC}/static/h-ui/images/del.png) no-repeat;background-size:contain;height: 20px;width: 20px;position: absolute;z-index: 10;right: 5px;"></div>'+
                    '<img style="width: 100px;height: 100px;">' +
                    '<input name="logo[]" type="hidden" value="">'+
                    '<div class="info">' + file.name + '</div>' +
                    '</div>'
                ),
                $img = $li.find('img');


            // $list为容器jQuery实例
            $list.append( $li );

            // 创建缩略图
            // 如果为非图片文件，可以不用调用此方法。
            // thumbnailWidth x thumbnailHeight 为 100 x 100
            uploader.makeThumb( file, function( error, src ) {
                if ( error ) {
                    $img.replaceWith('<span>不能预览</span>');
                    return;
                }

                $img.attr( 'src', src );
            }, 100, 100 );
        });



        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress span');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<p class="progress"><span></span></p>')
                    .appendTo( $li )
                    .find('span');
            }


            $percent.css( 'width', percentage * 100 + '%' );
        });
    var s=[];
        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
        uploader.on( 'uploadSuccess', function( file,res ) {
            var data = JSON.parse(res._raw);
            if(data.errcode==300){
                layer.alert(data.msg);
            }
            var url = data.data;
            count+=1;
            $( '#'+file.id).find("logo").attr("src",url);
            $( '#'+file.id).find("input").val(url);
            $( '#'+file.id ).addClass('upload-state-done');
        });

        // 文件上传失败，显示上传出错。
        uploader.on( 'uploadError', function( file ) {
            var $li = $( '#'+file.id ),
                $error = $li.find('div.error');

            // 避免重复创建
            if ( !$error.length ) {
                $error = $('<div class="error"></div>').appendTo( $li );
            }

            $error.text('上传失败');
        });

        // 完成上传完了，成功或者失败，先删除进度条。
        uploader.on( 'uploadComplete', function( file ) {
            $( '#'+file.id ).find('.progress').remove();
        });
    });
    /**
     * 上传定金
     */
    $("#img-changes").click(function () {
        $("#files").click();
    });

    function delParents(object){
        $(object).parent().remove();
        count-=1;
    }
    var count=1;
    $(function(){
        var $list = $("#fileLists");
        var uploader = WebUploader.create({
            auto: true,
            // 文件接收服务端。
            server: "{:Url('index/upload/upload_file')}",

            // 选择文件的按钮。可选。
            pick: '#filePickers',

            // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
            resize: false,
            duplicate:true,
            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: 'image/*'
            },
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            var $li = $(
                    '<div id="' + file.id + '" class="file-item thumbnail">' +
                    '<div onclick="delParent(this)" style="cursor: pointer;background: url({$Think.DOMAIN_SRC}/static/h-ui/images/del.png) no-repeat;background-size:contain;height: 20px;width: 20px;position: absolute;z-index: 10;right: 5px;"></div>'+
                    '<img style="width: 100px;height: 100px;">' +
                    '<input name="logos[]" type="hidden" value="">'+
                    '<div class="info">' + file.name + '</div>' +
                    '</div>'
                ),
                $img = $li.find('img');


            // $list为容器jQuery实例
            $list.append( $li );

            // 创建缩略图
            // 如果为非图片文件，可以不用调用此方法。
            // thumbnailWidth x thumbnailHeight 为 100 x 100
            uploader.makeThumb( file, function( error, src ) {
                if ( error ) {
                    $img.replaceWith('<span>不能预览</span>');
                    return;
                }

                $img.attr( 'src', src );
            }, 100, 100 );
        });



        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress span');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<p class="progress"><span></span></p>')
                    .appendTo( $li )
                    .find('span');
            }


            $percent.css( 'width', percentage * 100 + '%' );
        });
        var s=[];
        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
        uploader.on( 'uploadSuccess', function( file,res ) {
            var data = JSON.parse(res._raw);
            if(data.errcode==300){
                layer.alert(data.msg);
            }
            var url = data.data;
            count+=1;
            $( '#'+file.id).find("logo").attr("src",url);
            $( '#'+file.id).find("input").val(url);
            $( '#'+file.id ).addClass('upload-state-done');
        });

        // 文件上传失败，显示上传出错。
        uploader.on( 'uploadError', function( file ) {
            var $li = $( '#'+file.id ),
                $error = $li.find('div.error');

            // 避免重复创建
            if ( !$error.length ) {
                $error = $('<div class="error"></div>').appendTo( $li );
            }

            $error.text('上传失败');
        });

        // 完成上传完了，成功或者失败，先删除进度条。
        uploader.on( 'uploadComplete', function( file ) {
            $( '#'+file.id ).find('.progress').remove();
        });
    });


</script>
</body>
</html>